package com.nineclock.system.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.nineclock.system.pojo.SysCompanyUser;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * @author 黑马程序员
 * @Company http://www.ithiema.com
 * @Version 1.0
 */
@Mapper
public interface SysCompanyUserMapper extends BaseMapper<SysCompanyUser> {

    @Select("SELECT\n" +
            "\tscu.* \n" +
            "FROM\n" +
            "\tsys_company_user scu,\n" +
            "\tsys_company_user_role scur,\n" +
            "\tsys_role r \n" +
            "WHERE\n" +
            "  scu.company_id = #{companyId} \n" +
            "\tAND scur.company_user_id = scu.id\n" +
            "\tAND scur.role_id = r.id\n" +
            "\tAND r.role_name = \"ROLE_ADMIN_SYS\"")
    SysCompanyUser findCurrentAdmin(@Param("companyId") Long companyId);
}
